//
//  CityDetailView.m
//  Funny
//
//  Created by dllo on 15/10/29.
//  Copyright © 2015年 King. All rights reserved.
//

#import "CityDetailView.h"

@implementation CityDetailView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self creatButton];
    }
    return self;
}


// 定义View上的button和lable
- (void)creatButton
{
    NSArray *imgArr = @[@"food@2x.png", @"shopping@2x.png", @"life@2x.png", @"grogshop@2x.png"];
    NSArray *nameArr = @[@"美食",@"购物",@"游玩",@"酒店"];
    for (int i = 0; i < 4; i++) {
        UIButton *button = [UIButton buttonWithFrame:CGRectMake(375 * W / 4 * i + 10, 10, 60, 60) color:nil title:nil type:UIButtonTypeSystem target:self action:@selector(ActionClick:) event:UIControlEventTouchUpInside cornerRadius:30.0];
        [self addSubview:button];
        button.tag = 20 + i;
        [button setBackgroundImage:[UIImage imageNamed:imgArr[i]] forState:UIControlStateNormal];
        UILabel *name = [[UILabel alloc]initWithFrame:CGRectMake(375 / 4 * W * i  + 25, 73, 60, 30)];
        name.textColor = [UIColor whiteColor];
        [self addSubview:name];
        name.text = nameArr[i];
    }
}

// 将button对应的key传到外面用于拼接url

- (void)ActionClick:(UIButton *)btn
{
    NSArray *arr = @[@"cy",@"gw",@"jd",@"hotel"];
    [self.delegate pushToNextWithType:arr [(btn.tag - 20)]];
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
